package com.zengqingfa.designpattern.create.factory.simple;

/**
 *
 * @fileName: ProductFactory
 * @author: zengqf3
 * @date: 2021-4-21 16:09
 * @description:
 */
public class ProductFactory {

    /**
     * 创建产品
     * @param type
     * @return
     */
    public  Product createProduct1(Integer type) {
        if (!ProductEnum.checkIn(type)) {
            return null;
        }
        switch (type) {
            case 1:
                return new ConcreteProduct1();
            case 2:
                return new ConcreteProduct2();
            default:
                return null;
        }
    }


    /**
     * 创建产品
     * @param type
     * @return
     */
    public  static Product createProduct2(Integer type) {
        if (!ProductEnum.checkIn(type)) {
            return null;
        }
        switch (type) {
            case 1:
                return new ConcreteProduct1();
            case 2:
                return new ConcreteProduct2();
            default:
                return null;
        }
    }


}
